package me.jessyan.armscomponent.app.di.module;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.utils.ArmsUtils;

import java.util.ArrayList;
import java.util.List;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import me.jessyan.armscomponent.app.mvp.contract.mine.MineMyNotesContract;
import me.jessyan.armscomponent.app.mvp.model.mine.MineMyNotesModel;
import me.jessyan.armscomponent.app.mvp.model.entity.NoteItem;
import me.jessyan.armscomponent.app.mvp.ui.adapter.MineNoteAdapter;


/**
 * <p>
 * Author: Taozebi
 * Date: 09/08/2021 20:47
 * Description: describe of this class
 */
@Module
public abstract class MineMyNotesModule {

    @Binds
    abstract MineMyNotesContract.Model bindMineMyNotesModel(MineMyNotesModel model);

    @ActivityScope
    @Provides
    static RecyclerView.LayoutManager provideLayoutManager(MineMyNotesContract.View view) {
        return new LinearLayoutManager(view.getActivity());
    }

    @ActivityScope
    @Provides
    static List<NoteItem> provideList() {
        return new ArrayList<>();
    }

    @ActivityScope
    @Provides
    static RecyclerView.Adapter provideMineMyNotesAdapter(MineMyNotesContract.View mineMyNotesView,List<NoteItem> list) {
        MineNoteAdapter adapter = new MineNoteAdapter(list);
        adapter.setOnItemClickListener(new DefaultAdapter.OnRecyclerViewItemClickListener<NoteItem>() {
            @Override
            public void onItemClick(@NonNull View view, int viewType, @NonNull NoteItem data, int position) {
                ArmsUtils.snackbarText("position:"+position);
            }
        });
        return adapter;
    }
}